package com.aaa.controller.api;

import com.aaa.entity.Dept;
import com.aaa.entity.DictType;
import com.aaa.entity.LoginInfo;
import com.aaa.service.LoginInfoService;
import com.aaa.vo.DictTypeVo;
import com.aaa.vo.LoginInfoVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/api/loginLog")
public class LoginInfoControllerApi {
    @Autowired
    private LoginInfoService loginInfoService;
    @PostMapping("searchLoginLog/{currentPage}/{pageSize}")
    public Result<IPage<LoginInfo>> searchLoginLog(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody LoginInfoVo loginInfoVo
    ){
        return loginInfoService.findByConditions(currentPage,pageSize, loginInfoVo);
    }


    //删除
    @DeleteMapping("delById/{id}")
    public Result delById(@PathVariable Long id){
        if (loginInfoService.delById(id)){
            return new Result(200,"修改成功",true);
        }else {
            return  new Result(500,"修改失败",false);
        }
    }
    //批量删除
    @PostMapping("delListById")
    public Result delListByid(@RequestBody List<LoginInfo> loginInfoList){
        loginInfoList.forEach((LoginInfo loginInfo)->{
            loginInfoService.removeById(loginInfo.getInfoId());
        });
        return new Result(200,"批量删除成功",true);
    }
}
